home *** CD-ROM | disk | FTP | other *** search
/ F1 Licenseware / F1 Licenseware - Volume 1.iso / disks / 028.dms / 028.adf / Features_of_the_Shell / Wildcards < prev    next >
Text File  |  1992-02-26  |  4KB  |  87 lines

  1.                               Wildcards
  2.  
  3. Wildcards are a special type of character that AmigaDOS uses to choose, for
  4. example, multiple files.  A wildcard can save you from typing a long 
  5. filename by typing in the first few letters then putting the wildcard #?.
  6. This tells AmigaDOS that all commands beginning with the string you typed
  7. are to be the argument you have passed.  Wildcards are difficult to get to
  8. grasps with at first (let's face it - so is AmigaDOS itself :-) but are well
  9. worth using once you have learned them.
  10.  
  11. A few examples might help.
  12.  
  13. Am#? means any file beginning with Am and ending with any number of 
  14. characters are specified.  In a practical situation, you could use this 
  15. command to copy all related files for a program to a destination.  Say you 
  16. have the application program MakeDisk on your Workbench disk but would like 
  17. to  copy it to another disk, MyDisk:.  MakeDisk has also got three 
  18. accompanying files with it - MakeDiskB, MakeDisk.setup and MakeADisk.
  19.  
  20. To copy all three you will need to work out the place to cut off the 
  21. command.  You could use M#? to copy all files beginning with M.  But what
  22. if you had a directory on your Workbench disk called Maths?  If you used
  23. the M#? argument that directory would also be copied.  MakeDisk#? would copy
  24. three of the files but the file MakeADisk would not be copied.  So your best
  25. bet would be to issue the command
  26.  
  27.                 Copy FROM Workbench2.0:Make#? TO MyDisk:
  28.  
  29. Now all four files will be copied, under their original names, to MyDisk:.
  30.  
  31. Of course, there are more wildcards.  The rest of them are:
  32.  
  33.         ?               Is used to match any single character.  B?D matches
  34.                         any file with a name three letters long that begins
  35.                         with B and ends with D.  For example BAD, BED and
  36.                         BID (if they were in the current directory) would be
  37.                         matched.  More than one can be used, either together
  38.                         or apart.  ??????? matches all filenames seven 
  39.                         letters long and H?L?O matches all filenames  that 
  40.                         are five letters long, beginning with H, with an L
  41.                         as the middle character and ending with O.
  42.  
  43.         #<p>            Where <p> is replaced by any character(s).  The 
  44.                         wildcard in the above example was formed by this
  45.                         wildcard.  What #<p> does is match zero or more
  46.                         occurrences of <p>.  This is a complicated command
  47.                         with a lot of scope.  Some examples are:
  48.  
  49.                                 A#BC matches any character beginning with A,
  50.                                 ending with C and with any number of Bs 
  51.                                 in between.  SO some matches could be ABC,
  52.                                 ABBC or AC (AC is a match because it has no
  53.                                 Bs in it - remember, it checks for zero or
  54.                                 more occurrences, not one or more.  #? 
  55.                                 matches any character.
  56.  
  57.         <p1>|<p2>       Matches either <p1> or <p2>.  For example
  58.  
  59.                                 File(A|B)name would match either FileAname
  60.                                 or FileBname.                                         
  61.  
  62.         ~<p>            Matches everything except the text specified in <p>.
  63.                         (~#?.doc) matches all files except files that end in
  64.                         .doc (text files).
  65.  
  66.         %               Matches the null string.
  67.  
  68.                                 A(B|D|%)#C matches ABC, ADC, AC, ABCC, ADCC,
  69.                                 ACCC, etc.
  70.  
  71. If you have a filename containing one of the wildcard definition characters,
  72. for example "NoSampler?" or "File#1" you will find it gets mistaken for a
  73. wildcard definition.  To avoid this, you must precede the guilty character
  74. with an apostrophe (').  An example -
  75.  
  76.         Copy FROM SYS:NoSampler? TO DF1:
  77.  
  78. This will copy the file NoSampler? to the disk in drive 1.  It will also
  79. copy files with names like NoSampler1, NoSamplers or NoSampler!.  If you
  80. only want the file "NoSampler?" copying you must use the line
  81.  
  82.         Copy FROM SYS:NoSampler'? TO Df1:
  83.  
  84. Now only the file "NoSampler" is copied.  The files like NoSampler1 will be
  85. left untouched.
  86.  
  87.